﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MainTemplate.Master" AutoEventWireup="true" CodeBehind="Recruitment.aspx.cs" Inherits="Enterprise.Admin.Recruitment" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="../Content/Widget/jquery.json.min.js" type="text/javascript" charset="utf-8"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table id="table_list"></table>
    <div id="search_recruitment">
        <form id="search_recruitment_form">
            <p>
                <label>岗位：</label><input type="text" name="CoPost" />
            </p>
        </form>
    </div>
    <div id="add_recruitment">
        <form id="add_recruitment_form">
            <div id="add_recruitment_tabs" style="padding: 0px; height: auto">
                <div title="岗位信息">
                    <p>
                        <label>岗位：</label><input type="text" name="CoPost" />
                    </p>
                    <p>
                        <label>招聘人数：</label><input type="text" name="CoNumber" />
                    </p>
                    <p>
                        <label>月薪：</label><input type="text" name="CoMonthlySalary" />
                    </p>
                    <p>
                        <label>工作类型：</label><input type="text" name="CoWorkType" />
                    </p>
                    <p>
                        <label>工作地点：</label><input type="text" name="CoWorkPlace" />
                    </p>

                    <p>
                        <label>发布日期：</label><input type="text" name="CoDate" value="<%=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") %>" class="easyui-datetimebox easyui-validatebox" validtype="datetime" />
                    </p>
                    <p>
                        <label>有效期：</label><input type="text" name="CoValidDate" value="<%=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") %>" class="easyui-datetimebox easyui-validatebox" validtype="datetime" />
                    </p>


                </div>
                <div title="岗位要求">
                    <p>
                        <label>工作经验：</label><input type="text" name="CoWorkExperience" />
                    </p>
                    <p>
                        <label>教育程度：</label><input type="text" name="CoEducation" />
                    </p>
                    <p>
                        <label>年龄：</label><input type="text" name="CoAge" />
                    </p>
                    <p>
                        <label>性别：</label>男<input type="radio" name="CoSex" value="男" />女<input type="radio" name="CoSex" value="女" />
                    </p>
                    <p>
                        <label>语言要求：</label><input type="text" name="CoLanguage" />
                    </p>
                    <p>
                        <label>应聘方式：</label><input type="text" name="CoCandidates" />
                    </p>
                    <p>
                        <label>考核方式：</label><input type="text" name="CoAssess" />
                    </p>
                </div>
                <div title="岗位描述">
                    <textarea rows="10" cols="50" name="CoPostDescription"></textarea>
                </div>
                <div title="其他待遇">
                    <textarea rows="10" cols="50" name="CoOtherTreatment"></textarea>
                </div>
            </div>
        </form>
    </div>
    <div id="edit_recruitment">
        <form id="edit_recruitment_form">

            <div id="edit_recruitment_tabs" style="padding: 0px; height: auto">
                <div title="岗位信息">
                    <p>
                        <label>岗位：</label><input type="text" name="CoPost" /><input type="hidden" name="CoRecruitmentId" />
                    </p>
                    <p>
                        <label>招聘人数：</label><input type="text" name="CoNumber" />
                    </p>
                    <p>
                        <label>月薪：</label><input type="text" name="CoMonthlySalary" />
                    </p>
                    <p>
                        <label>工作类型：</label><input type="text" name="CoWorkType" />
                    </p>
                    <p>
                        <label>工作地点：</label><input type="text" name="CoWorkPlace" />
                    </p>

                    <p>
                        <label>发布日期：</label><input type="text" name="CoDate" value="<%=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") %>" class="easyui-datetimebox easyui-validatebox" validtype="datetime" />
                    </p>
                    <p>
                        <label>有效期：</label><input type="text" name="CoValidDate" value="<%=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") %>" class="easyui-datetimebox easyui-validatebox" validtype="datetime" />
                    </p>
                </div>
                <div title="岗位要求">
                    <p>
                        <label>工作经验：</label><input type="text" name="CoWorkExperience" />
                    </p>
                    <p>
                        <label>教育程度：</label><input type="text" name="CoEducation" />
                    </p>
                    <p>
                        <label>年龄：</label><input type="text" name="CoAge" />
                    </p>
                    <p>
                        <label>性别：</label>男<input type="radio" name="CoSex" value="男" />女<input type="radio" name="CoSex" value="女" />
                    </p>
                    <p>
                        <label>语言要求：</label><input type="text" name="CoLanguage" />
                    </p>
                    <p>
                        <label>应聘方式：</label><input type="text" name="CoCandidates" />
                    </p>
                    <p>
                        <label>考核方式：</label><input type="text" name="CoAssess" />
                    </p>
                </div>
                <div title="岗位描述">
                    <textarea rows="10" cols="50" name="CoPostDescription"></textarea>
                </div>
                <div title="其他待遇">
                    <textarea rows="10" cols="50" name="CoOtherTreatment"></textarea>
                </div>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            var tableList = $("#table_list").datagrid({
                title: '招聘信息列表',
                fit: true,
                nowrap: true,
                autoRowHeight: false,
                striped: true,
                collapsible: true,
                url: 'Handle/GetRecruitmentListJson.aspx',
                idField: 'id',
                singleSelect: true,
                fitColumns: true,
                onClickRow: function (rowIndex, rowData) {
                    $('#table_list').datagrid("unselectRow", rowIndex);
                },
                columns: [[
                         { title: 'Id', field: 'id', width: 280, align: 'center', checkbox: true },
                         { title: '岗位', field: 'CoPost', width: 280, align: 'center' },
                         { title: '招聘人数', field: 'CoNumber', width: 100, align: 'center' },
                         { title: '应聘方式', field: 'CoAssess', width: 100, align: 'center' },
                         { title: '发布日期', field: 'CoDate', width: 180, align: 'center' },

                       {
                           title: '修改', field: 'OpEdit', width: 80, align: 'center', formatter: function (value, rec, index) {
                               return '<a href="javascript:void(0);" mce_href="#" onclick="edit(\'' + rec.id + '\')">修改</a> ';
                           }
                       },
                        {
                            title: '删除', field: 'OpDelete', width: 80, align: 'center', formatter: function (value, rec, index) {
                                return '<a href="javascript:void(0);" mce_href="#" onclick="del(\'' + rec.id + '\')">删除</a> ';

                            }
                        }
                ]],
                pagination: true,
                rownumbers: true,
                toolbar: [{
                    text: '添加',
                    iconCls: 'icon-add',
                    handler: function () {
                        add();
                    }
                }, {
                    text: '修改',
                    iconCls: 'icon-edit',
                    handler: function () {
                        var selectData = $('#table_list').datagrid('getSelected');
                        if (selectData == null) {
                            $.messager.show({
                                title: '提示',
                                msg: '请选择要修改记录！',
                                timeout: 5000,
                                showType: 'fade'
                            });
                        } else {
                            edit(selectData.id);
                        }
                    }

                }, {
                    text: '删除',
                    iconCls: 'icon-remove',
                    handler: function () {
                        var selectData = $('#table_list').datagrid('getSelected');
                        if (selectData == null) {
                            $.messager.show({
                                title: '提示',
                                msg: '请选择要删除记录！',
                                timeout: 5000,
                                showType: 'fade'
                            });
                        } else {
                            del(selectData.id);
                        }

                    }

                }, {
                    text: '查找',
                    iconCls: 'icon-search',
                    handler: function () {
                        $('#search_recruitment').dialog("open");
                    }

                }]
            });
            $('#add_recruitment').dialog({
                title: '添加招聘信息',

                width: 750,
                height: 500,
                closed: true,
                buttons: [{
                    text: '保存',
                    iconCls: 'icon-ok',
                    handler: function () {
                        addSave(function () { });
                    }
                }, {
                    text: '关闭',
                    handler: function () {
                        $('#add_recruitment').dialog('close');
                    }
                }]

            });
            $('#edit_recruitment').dialog({
                title: '修改招聘信息',

                width: 750,
                height: 500,
                closed: true,
                buttons: [{
                    text: '保存',
                    iconCls: 'icon-ok',
                    handler: function () {

                        editSave();
                    }
                }, {
                    text: '关闭',
                    handler: function () {
                        $('#edit_recruitment').dialog('close');
                    }
                }]
            });
            $('#search_recruitment').dialog({
                title: '检索招聘信息',
                width: 400,
                height: 250,
                closed: true,
                buttons: [{
                    text: '查找',
                    iconCls: 'icon-ok',
                    handler: function () {
                        tableList.datagrid("reload", $('#search_recruitment_form').serializeObject());
                    }
                }, {
                    text: '关闭',
                    handler: function () {
                        $('#search_recruitment').dialog('close');
                    }
                }]
            });
            $('#edit_recruitment_form').form({
                onBeforeLoad: function () {
                },
                onLoadSuccess: function (data) {
                    $('#edit_date').datetimebox('setValue', data.CoDate);
                    $('#edit_date').datetimebox('setValue', data.CoDate);
                    $('#edit_recruitment').dialog("open");
                },
                onLoadError: function () {
                }
            });

            $('#add_recruitment_tabs').tabs({
                border: false
            });
            $('#edit_recruitment_tabs').tabs({
                border: false
            });


        });
        //获取招聘信息详细
        function edit(id) {
            $('#edit_recruitment_form').form('load', 'Handle/GetrecRuitmentDetailJson.aspx?id=' + id);
        }
        function del(id) {
            $.messager.confirm("提示", "确认删除?", function (b) {
                if (b) {
                    $.ajax({
                        type: "POST",
                        url: "Handle/DeleteRecruitment.aspx",
                        data: { id: id },
                        success: function (msg) {
                            $.messager.show({
                                title: '提示',
                                msg: msg.message,
                                timeout: 5000,
                                showType: 'fade'
                            });
                            if (msg.state)
                                $("#table_list").datagrid("reload");
                        },
                        error: function () {
                            $.messager.show({
                                title: '提示',
                                msg: '删除失败！',
                                timeout: 5000,
                                showType: 'fade'
                            });
                        }
                    });
                }

            });

        }
        function add() {
            $('#add_recruitment').dialog("open");
        }
        //添加保存
        function addSave(fn) {
            $.ajax({
                type: "POST",
                url: "Handle/AddRecruitment.aspx",
                data: $('#add_recruitment_form').serialize(),
                success: function (msg) {
                    $.messager.show({
                        title: '提示',
                        msg: msg.message,
                        timeout: 5000,
                        showType: 'fade'
                    });
                    if (msg.state)
                    {
                        $('#add_recruitment_form')[0].reset();
                        $("#table_list").datagrid("reload");
                    }
                },
                error: function () {
                    $.messager.show({
                        title: '提示',
                        msg: '保存失败！',
                        timeout: 5000,
                        showType: 'fade'
                    });
                }
            });
        }
        //编辑保存
        function editSave(fn) {
            $.ajax({
                type: "POST",
                url: "Handle/EditRecruitment.aspx",
                data: $('#edit_recruitment_form').serialize(),
                success: function (msg) {
                    $.messager.show({
                        title: '提示',
                        msg: msg.message,
                        timeout: 5000,
                        showType: 'fade'
                    });
                    if (msg.state)
                        $("#table_list").datagrid("reload");
                },
                error: function () {
                    $.messager.show({
                        title: '提示',
                        msg: '保存失败！',
                        timeout: 5000,
                        showType: 'fade'
                    });
                }
            });
        }
    </script>
</asp:Content>
